class Role < ApplicationRecord
  has_many :users
  #权限名称非空、唯一
  validates :name, uniqueness: true, presence: true
  #权限数值非空、唯一、为数字
  validates :privilege, uniqueness: true, presence: true, numericality: { only_integer: true}
  #搜索权限值大于某个值的记录,用于index记录展示
  scope :power, -> power { where("privilege < ?", power)}

end
